package com.example.demo.util;

import java.util.Collection;
import java.util.Map;

public class EmptyUtil {
	public static boolean isEmpty(Object obj){
		boolean isnull = false;
		
		if(null == obj){
			return true;
		}
		
		if(obj instanceof String){
			String str = (String)obj;
			if(0==str.trim().length()||"null".equals(str.trim())){
				isnull = true;
			}
		}else if(obj instanceof Collection){
			Collection coll = (Collection)obj;
			if(0==coll.size()){
				isnull = true;
			}
		}else if(obj instanceof Map){
			Map map = (Map)obj;
			if(0==map.size()){
				isnull = true;
			}
		}
		
		return isnull;
	}
	
	public static boolean isNotEmpty(Object obj){
		return !isEmpty(obj);
	}
}
